import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { resolve } from 'path'

export default defineConfig({
    plugins: [
        vue(),
        Components({
            resolvers: [ElementPlusResolver()],
            // 禁用自动导入样式，手动导入
            dts: false,
        }),
    ],

    resolve: {
        alias: {
            '@': resolve(__dirname, 'src')
        }
    },

    css: {
        preprocessorOptions: {
            scss: {
                // Modern Sass compiler options - 使用现代 Sass 编译器选项
                charset: false,
                quietDeps: true,
                style: 'expanded',
                // 添加现代 Sass 配置来避免旧版 API 警告
                api: 'modern-compiler',
                // 确保使用现代语法
                modern: true,
                // 禁用旧版兼容性警告
                legacy: false
            }
        }
    },
    server: {
        open: false,
        port: 5173,
        proxy: {
            '/api': {// 匹配所有以 '/api'开头的请求路径
                target: 'https://aip.baidubce.com',// 代理目标的基础路径
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            }
        }
    }

})
